<script>
	export default {
		globalData() {
			return {
				stystem: {},
				text: '',
				canIUseGetUserProfile: false,
				firstapplet: false,
				// 商品真分享
				// targoodsid: 0,
				// useridres: 0,
				// mallid: 1
			}
		},
		onLaunch: function(options) {
			console.log('app onLaunch--->'); // 公众号文章进小程序无底部导航调试，请勿删除
			console.log(options); // 公众号文章进小程序无底部导航调试，请勿删除

			console.log('<---app onLaunch'); // 公众号文章进小程序无底部导航调试，请勿删除

			if (options && options.scene) {
				this.$appScene = options.scene;
			}
			if (uni.getUserProfile) {
				this.$scope.globalData.canIUseGetUserProfile = true
			}

			this.$scope.globalData.firstapplet = true
			// if (options.targoodsid) {
			// 	this.$scope.globalData.targoodsid = options.targoodsid
			// }
			// if (options.useridres) {
			// 	this.$scope.globalData.useridres = options.useridres
			// }
			// if (options.mallid) {
			// 	this.$scope.globalData.mallid = options.mallid
			// }
			// console.log(this.getApiRoot(1));
			// console.log(this.$store.state.apiurl.apirl,666);
			// console.log(this.$api,'APP.vue');
			// 基本信息
			this.$store.dispatch('mallConfig/actionGetConfig');
			// 商品真分享
			// this.$store.dispatch('user/goodshare', options.query)
			let _this = this;
			// 系统信息
			wx.getSystemInfo({
				success: function(response) {
					_this.$store.dispatch('gConfig/setSystemInfo', response);
					_this.$store.dispatch('iPhoneX/setIphone', response);
				}
			});
			// #ifdef MP_WEIXIN
			if (options.scene == '1011' || options.scene == '1012' || options.scene == '1013' ||
				options.scene == '1047' || options.scene == '1048' || options.scene == '1049') {
				this.$store.dispatch('page/actionSetIsScanQrCode', true);
			}
			// #endif
			// #ifdef MP-ALIPAY
			if (typeof options.query != 'undefined') {
				this.$store.dispatch('page/actionSetQeury', options.query)
			}
			// #endif
			if (options.query && typeof options.query.user_id !== 'undefined') {
				this.$store.dispatch('user/setTempParentId', options.query.user_id)
			}

			// 9.27 好货快快抢的时间 有待商榷
			let gospeedtimer = this.$storage.getStorageSync('gospeedtimer')
			if (gospeedtimer) {
				this.$storage.removeStorageSync('gospeedtimer')
			}
		},
		onShow(options) {
			console.log('app onShow--->'); // 公众号文章进小程序无底部导航调试，请勿删除
			console.log(options); // 公众号文章进小程序无底部导航调试，请勿删除
			console.log('<---app onShow'); // 公众号文章进小程序无底部导航调试，请勿删除
			if (options && options.scene) {
				this.$appScene = options.scene;
			}
			// #ifdef MP-WEIXIN
			this.$user.silentLogin();
			// #endif
			// 商品真分享
			let aprms = null
			if (options.query.params) {
				aprms = JSON.parse(options.query.params)
				// console.log(aprms);
				if (aprms.path && aprms.path != '/pages/index/index') {
					if (aprms.useridres && aprms.useridres != 0 && aprms.targoodsid && aprms.targoodsid != 0) {
						this.$store.dispatch('user/goodshare', aprms)
					}
				} else {
					if (options.query.useridres && options.query.useridres != 0 && options.query.targoodsid && options
						.query.targoodsid != 0) {
						this.$store.dispatch('user/goodshare', options.query)
					}
				}
			} else {
				if (options.query.useridres && options.query.useridres != 0 && options.query.targoodsid && options.query
					.targoodsid != 0) {
					this.$store.dispatch('user/goodshare', options.query)
				}
			}
		},
		onHide: function(options) {
			console.log('<--onHide-->');
			// let pages = getCurrentPages();
			// console.log(pages[pages.length-1].route);
			// console.log(pages[pages.length-1].route != 'pages/index/index');
			/* if (pages[pages.length-1].route != 'pages/index/index') {
				uni.reLaunch({
					url: 'pages/index/index'
				})
			} */
			let that = this
			// 分享者id
			let sharestoreid = that.$storage.getStorageSync('sharestoreid')
			if (sharestoreid) {
				that.$storage.removeStorageSync('sharestoreid')
			}
			let jewelstoreid = that.$storage.getStorageSync('jewelstoreid')
			if (jewelstoreid) {
				that.$storage.removeStorageSync('jewelstoreid')
			}
			// 9.22 好货快快抢的时间 有待商榷
			let gospeedtimer = that.$storage.getStorageSync('gospeedtimer')
			if (gospeedtimer) {
				that.$storage.removeStorageSync('gospeedtimer')
			}
		},
		onUnload(options) {
			console.log('<---onUnload--->');
			let sharestoreid = this.$storage.getStorageSync('sharestoreid')
			if (sharestoreid) {
				this.$storage.removeStorageSync('sharestoreid')
			}
			let jewelstoreid = this.$storage.getStorageSync('jewelstoreid')
			if (jewelstoreid) {
				this.$storage.removeStorageSync('jewelstoreid')
			}
			let gospeedtimer = this.$storage.getStorageSync('gospeedtimer')
			if (gospeedtimer) {
				this.$storage.removeStorageSync('gospeedtimer')
			}
		}
	};
</script>

<style lang="scss">
	/*每个页面公共css */
	// @import "./uni.scss";
	@import "./static/css/flex.scss";
	@import "./static/css/themeColor.scss";
	@import "./static/css/text.scss";
	@import "./static/css/image.scss";
	@import "./static/css/parse.scss";
	@import "./static/css/gift.scss";
	@import "./static/css/u-index.scss";
	@import "./static/css/border-box.scss";
	@import './static/css/iconfont.css';

	page {
		-webkit-overflow-scrolling: touch;
	}
	.image-bg {
    position: absolute;
    z-index: -1;
    left: 0;
    right: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
}

	.u-goods-detail {
		background-image: url("./static/image/goods.png");
		background-repeat: no-repeat;
		background-size: 100% 100%;
		min-height: 100vh;
	}

	.u-border-box {
		box-sizing: border-box;
	}
</style>
